﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using Portal.Environment;
using Portal.Language;
using Portal.Interface;

namespace Portal.CMS
{
    public class NewsPreview : WebPart
    {
       // protected global::FredCK.FCKeditorV2.FCKeditor FCKeditorBody;
       // protected global::FredCK.FCKeditorV2.FCKeditor FCKeditorShortContent;
        public override string WebPartId
        {
            get
            {
                return "NewsPreview";
            }
        }

        public override string Title
        {
            get
            {
                return ResourceBLL.GetText(WebPartId,"Title","Xem tin tức");
            }
        }

        public override string Description
        {
            get
            {
                return ResourceBLL.GetText(WebPartId,"Description","");
            }
        }

        public override string RenderWebPart(LoadParamCls loadParamCls)
        {
            try
            {
                string NewsId = System.Web.HttpContext.Current.Request["RecordId"];
                NewsCls NewsCls = new NewsBLL().CreateModel(Environments.ActiveLanguage, NewsId);
                if (NewsCls == null)
                {
                    return ResourceBLL.GetText(WebPartId, "NotFound", "Không tìm thấy bản ghi news");
                }
                string 
                    RetHtml =  "<div class=cssPreviewNewsShort><div class=cssPreviewNewsShortTitle>" + ResourceBLL.GetText(WebPartId, "ShortContent", "Nội dung ngắn") + "</div>" + NewsCls.ShortContent + "</div>";
                    RetHtml += "<div class=cssPreviewNewsBody><div class=cssPreviewNewsBodyTitle>" + ResourceBLL.GetText(WebPartId, "Body", "Nội dung") + "</div>" + NewsCls.ShortContent + "</div>";
                return RetHtml;
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }
    }
}